package com.hcss.core.util;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.regex.Pattern;

public class DateUtil {

	// 格式：年－月－日 小时：分钟：秒
	public static final String FORMAT_ONE = "yyyy-MM-dd HH:mm:ss";

	// 格式：年－月－日 小时：分钟
	public static final String FORMAT_TWO = "yyyy-MM-dd HH:mm";

	// 格式：年月日 小时分钟秒
	public static final String FORMAT_THREE = "yyyyMMdd-HHmmss";

	// 格式：年月日小时分钟
	public static final String FORMAT_FOUR = "yyyyMMddHHmm";

	// 格式：年－月－日
	public static final String LONG_DATE_FORMAT = "yyyy-MM-dd";

	// 格式：年月日
	public static final String FLOW_DATE_FORMAT = "yyyyMMdd";

	// 格式：月－日
	public static final String SHORT_DATE_FORMAT = "MM-dd";
	// 生日格式
	public static final String SHORTEST_DATE_FORMAT = "MMdd";

	// 格式：小时：分钟：秒
	public static final String LONG_TIME_FORMAT = "HH:mm:ss";

	// 格式：年-月
	public static final String MONTH_DATE_FORMAT = "yyyy-MM";
	// 格式：年-月
	public static final String MONTHDATE_FORMAT = "yyyyMM";
	public static final String SHORT_MONTHDATE_FORMAT = "yyMM";

	// 年的加减
	public static final int SUB_YEAR = Calendar.YEAR;

	// 月加减
	public static final int SUB_MONTH = Calendar.MONTH;

	// 天的加减
	public static final int SUB_DAY = Calendar.DATE;

	// 小时的加减
	public static final int SUB_HOUR = Calendar.HOUR;

	// 分钟的加减
	public static final int SUB_MINUTE = Calendar.MINUTE;

	// 秒的加减
	public static final int SUB_SECOND = Calendar.SECOND;

	static final String dayNames[] = { "星期日", "星期一", "星期二", "星期三", "星期四",
			"星期五", "星期六" };

	@SuppressWarnings("unused")
	private static final SimpleDateFormat timeFormat = new SimpleDateFormat(
			FORMAT_ONE);
	private static final DateFormat dateFormat = new SimpleDateFormat(LONG_DATE_FORMAT);

	public DateUtil() {
	}

	/**
	 * 把符合日期格式的字符串转换为日期类型
	 */
	public static java.util.Date stringToDate(String dateStr, String format) {
		Date d = null;
		SimpleDateFormat formater = new SimpleDateFormat(format);
		try {
			formater.setLenient(false);
			d = formater.parse(dateStr);
		} catch (Exception e) {
			// log.error(e);
			d = null;
		}
		return d;
	}

	/**
	 * 把符合日期格式的字符串转换为日期类型
	 */
	public static java.util.Date stringtoDate(String dateStr, String format,
			ParsePosition pos) {
		Date d = null;
		SimpleDateFormat formater = new SimpleDateFormat(format);
		try {
			formater.setLenient(false);
			d = formater.parse(dateStr, pos);
		} catch (Exception e) {
			d = null;
		}
		return d;
	}

	/**
	 * 把日期转换为字符串
	 */
	public static String dateToString(java.util.Date date, String format) {
		String result = "";
		SimpleDateFormat formater = new SimpleDateFormat(format);
		try {
			result = formater.format(date);
		} catch (Exception e) {
			// log.error(e);
		}
		return result;
	}

	/**
	 * 获取当前时间的指定格式
	 */
	public static String getCurrDate(String format) {
		return dateToString(new Date(), format);
	}

	public static String dateSub(int dateKind, String dateStr, int amount) {
		Date date = stringToDate(dateStr, FORMAT_ONE);
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(date);
		calendar.add(dateKind, amount);
		return dateToString(calendar.getTime(), FORMAT_ONE);
	}
	
	public static String dateSub(int dateKind, String format,String dateStr, int amount) {
		Date date = stringToDate(dateStr, format);
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(date);
		calendar.add(dateKind, amount);
		return dateToString(calendar.getTime(), format);
	}

	/**
	 * 日期添加
	 * 
	 * @param dateStr
	 *            日期字符串
	 * @param dateKind
	 *            要添加的类型：Calendar.MONTH
	 * @param amount
	 *            要添加的数量
	 * @return 日期字符串
	 */
	public static String dateSub(String dateStr, String format, int dateKind,
			int amount) {
		Date date = stringToDate(dateStr, format);
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(date);
		calendar.add(dateKind, amount);
		return dateToString(calendar.getTime(), format);
	}

	public static String monthSubDate(int amount, int dateDiff) {
		Date date = stringToDate(getNow(), FORMAT_ONE);
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(date);
		calendar.add(Calendar.MONTH, 1 + amount);
		int month = calendar.get(Calendar.MONTH);
		
		if (month == 0) {
			return calendar.get(Calendar.YEAR)-1 + "-"
					+ "12" + "-" + dateDiff;
		}else if (month < 10) {
			return calendar.get(Calendar.YEAR) + "-0"
					+ calendar.get(Calendar.MONTH) + "-" + dateDiff;
		} else {
			return calendar.get(Calendar.YEAR) + "-"
					+ calendar.get(Calendar.MONTH) + "-" + dateDiff;
		}

	}

	/**
	 * 两个日期相减
	 * 
	 * @return 相减得到的秒数
	 */
	public static long timeSub(String firstTime, String secTime) {
		long first = stringToDate(firstTime, FORMAT_ONE).getTime();
		long second = stringToDate(secTime, FORMAT_ONE).getTime();
		return (second - first) / 1000;
	}
	/**
	 * 两个日期相减
	 * 
	 * @return 相减得到的秒数
	 */
	public static long timeSub(String firstTime, String secTime,String formatter) {
		long first = stringToDate(firstTime, formatter).getTime();
		long second = stringToDate(secTime, formatter).getTime();
		return (second - first) / 1000;
	}

	/**
	 * 获得某月的天数
	 */
	public static int getDaysOfMonth(String year, String month) {
		int days = 0;
		if (month.equals("1") || month.equals("3") || month.equals("5")
				|| month.equals("7") || month.equals("8") || month.equals("10")
				|| month.equals("12")) {
			days = 31;
		} else if (month.equals("4") || month.equals("6") || month.equals("9")
				|| month.equals("11")) {
			days = 30;
		} else {
			if ((Integer.parseInt(year) % 4 == 0 && Integer.parseInt(year) % 100 != 0)
					|| Integer.parseInt(year) % 400 == 0) {
				days = 29;
			} else {
				days = 28;
			}
		}

		return days;
	}

	/**
	 * 获取某年某月的天数
	 */
	public static int getDaysOfMonth(int year, int month) {
		Calendar calendar = Calendar.getInstance();
		calendar.set(year, month - 1, 1);
		return calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
	}

	/**
	 * 获得当前日期
	 */
	public static int getToday() {
		Calendar calendar = Calendar.getInstance();
		return calendar.get(Calendar.DATE);
	}

	/**
	 * 获得当前月份
	 */
	public static int getToMonth() {
		Calendar calendar = Calendar.getInstance();
		return calendar.get(Calendar.MONTH) + 1;
	}

	/**
	 * 获得当前年份
	 */
	public static int getToYear() {
		Calendar calendar = Calendar.getInstance();
		return calendar.get(Calendar.YEAR);
	}

	/**
	 * 返回日期的天
	 */
	public static int getDay(Date date) {
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(date);
		return calendar.get(Calendar.DATE);
	}

	/**
	 * 返回日期的年
	 */
	public static int getYear(Date date) {
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(date);
		return calendar.get(Calendar.YEAR);
	}

	/**
	 * 返回日期的月份，1-12
	 */
	public static int getMonth(Date date) {
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(date);
		return calendar.get(Calendar.MONTH) + 1;
	}
	
	/**
	 * 返回日期的季度，1-4
	 */
	public static int getQuarter(Date date) {
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(date);
		int month = calendar.get(Calendar.MONTH) + 1;
		int quarter = 1;
		if (month <= 3) {
			quarter =  1;
		}else if (month <= 6) {
			quarter =  2;
		}else if (month <= 9) {
			quarter =  3;
		}else if (month <= 12) {
			quarter =  4;
		}
		return quarter;
	}

	/**
	 * 计算两个日期相差的天数，如果date2 > date1 返回正数，否则返回负数
	 */
	public static long dayDiff(Date date1, Date date2) {
		return (date2.getTime() - date1.getTime()) / 86400000;
	}

	/**
	 * 比较两个日期的年差
	 */
	public static int yearDiff(String before, String after) {
		Date beforeDay = stringToDate(before, LONG_DATE_FORMAT);
		Date afterDay = stringToDate(after, LONG_DATE_FORMAT);
		return getYear(afterDay) - getYear(beforeDay);
	}

	/**
	 * 比较指定日期与当前日期的差
	 */
	public static int yearDiffCurr(String after) {
		Date beforeDay = new Date();
		Date afterDay = stringToDate(after, LONG_DATE_FORMAT);
		return getYear(beforeDay) - getYear(afterDay);
	}

	/**
	 * 比较指定日期与当前日期的差
	 */
	public static long dayDiffCurr(String before) {
		Date currDate = DateUtil.stringToDate(getNow(), LONG_DATE_FORMAT);
		Date beforeDate = stringToDate(before, LONG_DATE_FORMAT);
		return (currDate.getTime() - beforeDate.getTime()) / 86400000;
	}

	/**
	 * 获取每月的第一周
	 */
	public static int getFirstWeekdayOfMonth(int year, int month) {
		Calendar c = Calendar.getInstance();
		c.setFirstDayOfWeek(Calendar.SATURDAY); // 星期天为第一天
		c.set(year, month - 1, 1);
		return c.get(Calendar.DAY_OF_WEEK);
	}

	/**
	 * 获取每月的最后一周
	 */
	public static int getLastWeekdayOfMonth(int year, int month) {
		Calendar c = Calendar.getInstance();
		c.setFirstDayOfWeek(Calendar.SATURDAY); // 星期天为第一天
		c.set(year, month - 1, getDaysOfMonth(year, month));
		return c.get(Calendar.DAY_OF_WEEK);
	}

	/**
	 * 获得当前日期字符串，格式"yyyy_MM_dd_HH_mm_ss"
	 * 
	 * @return
	 */
	/*
	 * public static String getCurrent() { Calendar cal =
	 * Calendar.getInstance(); cal.setTime(new Date()); int year =
	 * cal.get(Calendar.YEAR); int month = cal.get(Calendar.MONTH) + 1; int day
	 * = cal.get(Calendar.DAY_OF_MONTH); int hour =
	 * cal.get(Calendar.HOUR_OF_DAY); int minute = cal.get(Calendar.MINUTE); int
	 * second = cal.get(Calendar.SECOND); StringBuffer sb = new StringBuffer();
	 * sb.append(year).append("_").append(StringUtil.addzero(month, 2))
	 * .append("_").append(StringUtil.addzero(day, 2)).append("_")
	 * .append(StringUtil.addzero(hour, 2)).append("_").append(
	 * StringUtil.addzero(minute, 2)).append("_").append(
	 * StringUtil.addzero(second, 2)); return sb.toString(); }
	 */

	/**
	 * 获得当前日期字符串，格式"yyyy-MM-dd HH:mm:ss"
	 * 
	 * @return
	 */
	public static String getNow() {
		Calendar today = Calendar.getInstance();
		return dateToString(today.getTime(), FORMAT_ONE);
	}

	/**
	 * 判断日期是否有效,包括闰年的情况
	 * 
	 * @param date
	 *            YYYY-mm-dd
	 * @return
	 */
	public static boolean isDate(String date) {
		StringBuffer reg = new StringBuffer(
				"^((\\d{2}(([02468][048])|([13579][26]))-?((((0?");
		reg.append("[13578])|(1[02]))-?((0?[1-9])|([1-2][0-9])|(3[01])))");
		reg.append("|(((0?[469])|(11))-?((0?[1-9])|([1-2][0-9])|(30)))|");
		reg.append("(0?2-?((0?[1-9])|([1-2][0-9])))))|(\\d{2}(([02468][12");
		reg.append("35679])|([13579][01345789]))-?((((0?[13578])|(1[02]))");
		reg.append("-?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))");
		reg.append("-?((0?[1-9])|([1-2][0-9])|(30)))|(0?2-?((0?[");
		reg.append("1-9])|(1[0-9])|(2[0-8]))))))");
		Pattern p = Pattern.compile(reg.toString());
		return p.matcher(date).matches();
	}

	/**
	 * 把sqlDate转换为utilDate
	 * 
	 * @param sqlDate
	 * @return
	 */
	public static java.util.Date sqlDateToUtilDate(java.sql.Date sqlDate) {
		return new java.util.Date(sqlDate.getTime());
	}

	/**
	 * 比较两个时间字符串
	 * 
	 * @param dateStr1
	 * @param dateStr2
	 * @return
	 * @throws ParseException
	 */
	public static int getDateDiff(String dateStr1, String dateStr2)
			throws ParseException {
		DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
		Date dateTime1 = dateFormat.parse(dateStr1);
		Date dateTime2 = dateFormat.parse(dateStr2);
		return dateTime1.compareTo(dateTime2);
	}

	/**
	 * 获取两个日期的差，后者减前者
	 * 
	 * @param dateStr1
	 * @param dateStr2
	 * @return
	 * @throws ParseException
	 */
	public static long getDateDiffDays(String dateStr1, String dateStr2)
			throws ParseException {
		DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
		Date dateTime1 = dateFormat.parse(dateStr1);
		Date dateTime2 = dateFormat.parse(dateStr2);
		return dayDiff(dateTime1, dateTime2);
	}

	public static String getFormatDateStr(String dateStr, String hour) {
		String[] array = dateStr.split("-");
		if (array.length >= 3) {
			return array[0] + "年" + array[1] + "月" + array[2] + "日 " + hour
					+ "时";
		} else {
			return "";
		}

	}

	/**
	 * 计算2个日期之间的工作日天数
	 * 
	 * @param d1
	 * @param d2
	 * @return
	 */
	public static int getWorkingDay(String strDateStart, String strDateEnd)
			throws ParseException {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		Date date_start = sdf.parse(strDateStart);
		Date date_end = sdf.parse(strDateEnd);
		Calendar cal_start = Calendar.getInstance();
		Calendar cal_end = Calendar.getInstance();
		cal_start.setTime(date_start);
		cal_end.setTime(date_end);
		int result = -1;
		if (cal_start.after(cal_end)) { // swap dates so that d1 is start and d2
										// is end
			java.util.Calendar swap = cal_start;
			cal_start = cal_end;
			cal_end = swap;
		}
		int charge_start_date = 0;// 开始日期的日期偏移量
		int charge_end_date = 0;// 结束日期的日期偏移量
		// 日期不在同一个日期内
		int stmp;
		int etmp;
		stmp = 7 - cal_start.get(Calendar.DAY_OF_WEEK);
		etmp = 7 - cal_end.get(Calendar.DAY_OF_WEEK);
		if (stmp != 0 && stmp != 6) {// 开始日期为星期六和星期日时偏移量为0
			charge_start_date = stmp - 1;
		}
		if (etmp != 0 && etmp != 6) {// 结束日期为星期六和星期日时偏移量为0
			charge_end_date = etmp - 1;
		}
		// }
		result = (getDaysBetween(getNextMonday(cal_start),
				getNextMonday(cal_end)) / 7)
				* 5
				+ charge_start_date
				- charge_end_date;
		return result;
	}

	public static int getDaysBetween(java.util.Calendar d1,
			java.util.Calendar d2) {
		if (d1.after(d2)) { // swap dates so that d1 is start and d2 is end
			java.util.Calendar swap = d1;
			d1 = d2;
			d2 = swap;
		}
		int days = d2.get(java.util.Calendar.DAY_OF_YEAR)
				- d1.get(java.util.Calendar.DAY_OF_YEAR);
		int y2 = d2.get(java.util.Calendar.YEAR);
		if (d1.get(java.util.Calendar.YEAR) != y2) {
			d1 = (java.util.Calendar) d1.clone();
			do {
				days += d1.getActualMaximum(java.util.Calendar.DAY_OF_YEAR);
				d1.add(java.util.Calendar.YEAR, 1);
			} while (d1.get(java.util.Calendar.YEAR) != y2);
		}
		return days;
	}

	/**
	 * 获得日期的下一个星期一的日期
	 * 
	 * @param date
	 * @return
	 */
	public static Calendar getNextMonday(Calendar date) {
		Calendar result = null;
		result = date;
		do {
			result = (Calendar) result.clone();
			result.add(Calendar.DATE, 1);
		} while (result.get(Calendar.DAY_OF_WEEK) != 2);
		return result;
	}

	public static void main(String[] args) {
//
//		String dateStr1 = "2013-7-17";
//		String dateStr2 = "2013-9-9";
//		try {
//			System.out.println(DateUtil.getDateDiffDays(dateStr1, dateStr2));
//			// System.out.println(DateUtil.getWorkingDay(dateStr2, dateStr1));
//		} catch (ParseException e) {
//			e.printStackTrace();
//		}
//		Calendar ca = Calendar.getInstance();
//		System.out.println(timeFormat.format(ca.getTime()));
//		ca.add(Calendar.DAY_OF_MONTH, -3);
//		System.out.println(timeFormat.format(ca.getTime()));

		// 2013-07-31

		// String dateStr = "2013-9-9";
		// System.out.println(DateUtil.dateSub(dateStr, LONG_DATE_FORMAT,
		// Calendar.DATE, -14));
		System.out.println(getCurrentWeekMonday(null));
		System.out.println(getCurrentWeekSunday(null));
		System.out.println(getPreviousWeekMonday(null));
		System.out.println(getPreviousWeekSunday(null));
		System.out.println(getNextWeekMonday(null));
		System.out.println(getNextWeekSunday(null));
		System.out.println("2013-10-11 00:00:00.0".substring(0, 10));
		Calendar ca = Calendar.getInstance();
		ca.setTimeInMillis(1386604800000L);
		System.out.println(dateToString(ca.getTime(), FORMAT_ONE));
	}

	// 获取今天在指定天数后的日期
	public static long getNextDayTime(int nextDay) {
		Calendar ca = Calendar.getInstance();
		ca.add(Calendar.DAY_OF_MONTH, nextDay);
		return ca.getTimeInMillis();
	}

	// 获得当前日期与本周日相差的天数
	private static int getMondayPlus(Date date) {
		Calendar cd = Calendar.getInstance();
		cd.setTime(date);
		// 获得今天是一周的第几天，星期日是第一天，星期二是第二天......
		int dayOfWeek = cd.get(Calendar.DAY_OF_WEEK) - 1; // 按礼拜一作为第一天所以这里减1
		if (dayOfWeek == 1){
			return 0;
		} else if(dayOfWeek == 0) {
			return -6;
		} else {
			return 1 - dayOfWeek;
		}
	}

	// 获得本周星期日的日期
	public static String getCurrentWeekSunday(String dateString) {
		Date date = null;
		try {
			date = StringUtils.isNotEmpty(dateString) ? dateFormat.parse(dateString) : new Date();
		} catch (ParseException e) {
			date =  new Date();
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		int mondayPlus = getMondayPlus(date);
		GregorianCalendar currentDate = new GregorianCalendar();
		currentDate.setTime(date);
		currentDate.add(GregorianCalendar.DATE, mondayPlus + 6);
		Date monday = currentDate.getTime();

		String preMonday = dateFormat.format(monday);
		return preMonday;
	}

	// 获得本周一的日期
	public static String getCurrentWeekMonday(String dateString) {
		Date date = null;
		try {
			date = StringUtils.isNotEmpty(dateString) ? dateFormat.parse(dateString) : new Date();
		} catch (ParseException e) {
			date =  new Date();
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		int mondayPlus = getMondayPlus(date);
		GregorianCalendar currentDate = new GregorianCalendar();
		currentDate.setTime(date);
		currentDate.add(GregorianCalendar.DAY_OF_MONTH, mondayPlus);
		Date monday = currentDate.getTime();

		String preMonday = dateFormat.format(monday);
		return preMonday;
	}

	// 获得上周星期日的日期
	public static String getPreviousWeekSunday(String dateString) {
		Date date = null;
		try {
			date = StringUtils.isNotEmpty(dateString) ? dateFormat.parse(dateString) : new Date();
		} catch (ParseException e) {
			date =  new Date();
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		int weeks = -1;
		int mondayPlus = getMondayPlus(date);
		GregorianCalendar currentDate = new GregorianCalendar();
		currentDate.setTime(date);
		currentDate.add(GregorianCalendar.DAY_OF_MONTH, mondayPlus + weeks);
		Date monday = currentDate.getTime();
		String preMonday = dateFormat.format(monday);
		return preMonday;
	}

	// 获得上周星期一的日期
	public static String getPreviousWeekMonday(String dateString) {
		Date date = null;
		try {
			date = StringUtils.isNotEmpty(dateString) ? dateFormat.parse(dateString) : new Date();
		} catch (ParseException e) {
			date =  new Date();
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		int weeks = -1;
		int mondayPlus = getMondayPlus(date);
		GregorianCalendar currentDate = new GregorianCalendar();
		currentDate.setTime(date);
		currentDate.add(GregorianCalendar.DATE, mondayPlus + 7 * weeks);
		Date monday = currentDate.getTime();
		String preMonday = dateFormat.format(monday);
		return preMonday;
	}

	// 获得下周星期一的日期
	public static String getNextWeekMonday(String dateString) {
		Date date = null;
		try {
			date = StringUtils.isNotEmpty(dateString) ? dateFormat.parse(dateString) : new Date();
		} catch (ParseException e) {
			date =  new Date();
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		int mondayPlus = getMondayPlus(date);
		GregorianCalendar currentDate = new GregorianCalendar();
		currentDate.setTime(date);
		currentDate.add(GregorianCalendar.DATE, mondayPlus + 7);
		Date monday = currentDate.getTime();
		String preMonday = dateFormat.format(monday);
		return preMonday;
	}

	// 获得下周星期日的日期
	public static String getNextWeekSunday(String dateString) {
		Date date = null;
		try {
			date = StringUtils.isNotEmpty(dateString) ? dateFormat.parse(dateString) : new Date();
		} catch (ParseException e) {
			date =  new Date();
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		int mondayPlus = getMondayPlus(date);
		GregorianCalendar currentDate = new GregorianCalendar();
		currentDate.setTime(date);
		currentDate.add(GregorianCalendar.DATE, mondayPlus + 7 + 6);
		Date monday = currentDate.getTime();
		String preMonday = dateFormat.format(monday);
		return preMonday;
	}
	/**  
     * 获得本季度
     * @param month 月  
     */ 
	public static int getThisSeason(int month){
		//int[][] array = {{1,2,3},{4,5,6},{7,8,9},{10,11,12}};
		int season = 1;
		if(month>=1&&month<=3)
			season = 1;
		if(month>=4&&month<=6)
			season = 2;
		if(month>=7&&month<=9)
			season = 3;
		if(month>=10&&month<=12) 
            season = 4;   
		/*int start_month = array[season-1][0];   
        int end_month = array[season-1][2];
        Date date = new Date();   
        SimpleDateFormat   dateFormat   =   new   SimpleDateFormat("yyyy");//可以方便地修改日期格式      
        String years  = dateFormat.format(date);      
        int years_value = Integer.parseInt(years); 
        int start_days =1;
        int end_days = getLastDayOfMonth(years_value,end_month); 
        String seasonDate = years_value+"-"+start_month+"-"+start_days+";"+years_value+"-"+end_month+"-"+end_days;   
        return seasonDate; */
		return season;
	}
	/**  
     * 获取某年某月的最后一天  
     * @param year 年  
     * @param month 月  
     * @return 最后一天  
     */  
	public static int getLastDayOfMonth(int year, int month){
		if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8  
                || month == 10 || month == 12) {   
            return 31;   
      }   
      if (month == 4 || month == 6 || month == 9 || month == 11) {   
            return 30;   
      }   
      if (month == 2) {   
            if (isLeapYear(year)) {   
                return 29;   
            } else {   
                return 28;   
            }   
      }   
      return 0;
	}
	/**  
	    * 是否闰年  
	    * @param year 年  
	    * @return   
	    */  
	  public static boolean isLeapYear(int year) {   
	        return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);   
	  }   
}
